load TagBlock,EventHeaders

if #msg="Media"
  Gosub TagBlock,"OBJE","Media"
  ShowAll SOUR "Media"
  hideexcess
  
else if #msg="Sources"
  if @count.SOUR+@count.NOTE>0
    newline
    #elabel=local(@tag)
    if @DATE!=""
      #elabel&=" ("&@DATE.user&")"
    endif
    cell static,#elabel
    set width -1 offset 3
    ShowAll NOTE
    ShowAll SOUR
  endif
  hideexcess
  
else if #msg="Box"
  use Event

else
  newline

  ! header on first event
  ifNDef #first
    #first="yes"
  endif
  if #first="yes"
    if #oneTable="yes"
      GoSub EventHeaders
    else
      newline 10

      cell static,local("Residence Date")
      set tabwidth 1 alignment center border square
      cellBackground "Table Cell Background"
      set borderColor "Table Cell Background" borderWidth 1

      cell static,local("Residence Place")
      set tabwidth 2 alignment center border square
      set width #cellWidth$+5
      cellBackground "Table Cell Background"
      set borderColor "Table Cell Background" borderWidth 1

      newline 1
      #first="no"
    endif
  endif
  
  if #oneTable="yes"
    cell static,local("RESI")
    set tabwidth 2 alignment center border square
    cellBackground "Table Cell Background"
    set borderColor "Table Cell Background" borderWidth 1
  endif
  
  show DATE Event
  show PLAC Event

  ! rest in a child window
  cell StructuresLink,AttrDetails,RESI
  set border no width -1
  if more
    set image "details_here"
  else
    set image "details"
  endif
  LinkAll all

  #tagKey=@tag&" details"
  help local("Click to edit")&": "&local(#tagKey)
endif
